package hcn.protocol.registration.xml.resp;

import ctd.util.JSONUtils;
import ctd.util.xml.jaxb.JAXBUtils;

import javax.xml.bind.annotation.*;
import java.util.List;

/**
 * @Author: lanyu
 * @Description:
 * @Date: create in 2023/2/23 17:52
 */
@XmlRootElement(name = "Data")
public class ExamineAppointmentXmlResponse {
    private Visit visit;
    private Patient patient;
    private List<ExamLabRequest> examLabRequests;

    @XmlElement(name = "Visit")
    public Visit getVisit() {
        return visit;
    }

    public void setVisit(Visit visit) {
        this.visit = visit;
    }

    @XmlElement(name = "Patient")
    public Patient getPatient() {
        return patient;
    }

    public void setPatient(Patient patient) {
        this.patient = patient;
    }

    @XmlElementWrapper(name = "LabRequests")
    @XmlElement(name = "LabRequest")
    public List<ExamLabRequest> getExamLabRequests() {
        return examLabRequests;
    }

    public void setExamLabRequests(List<ExamLabRequest> examLabRequests) {
        this.examLabRequests = examLabRequests;
    }

    public static class Visit {
        private String VisitId;
        private String VisitOrganization;
        private String VisitOrganizationName;
        private Integer PatientType;
        private String PatientTypeName;
        private Integer MedicalCardType;
        private String MedicalCardId;
        private Integer ForbidFlag;
        private String ForbidDescribe;

        @XmlElement(name = "VisitId")
        public String getVisitId() {
            return VisitId;
        }

        public void setVisitId(String visitId) {
            VisitId = visitId;
        }

        @XmlElement(name = "VisitOrganization")
        public String getVisitOrganization() {
            return VisitOrganization;
        }

        public void setVisitOrganization(String visitOrganization) {
            VisitOrganization = visitOrganization;
        }

        @XmlElement(name = "VisitOrganizationName")
        public String getVisitOrganizationName() {
            return VisitOrganizationName;
        }

        public void setVisitOrganizationName(String visitOrganizationName) {
            VisitOrganizationName = visitOrganizationName;
        }

        @XmlElement(name = "PatientType")
        public Integer getPatientType() {
            return PatientType;
        }

        public void setPatientType(Integer patientType) {
            PatientType = patientType;
        }

        @XmlElement(name = "PatientTypeName")
        public String getPatientTypeName() {
            return PatientTypeName;
        }

        public void setPatientTypeName(String patientTypeName) {
            PatientTypeName = patientTypeName;
        }

        @XmlElement(name = "MedicalCardType")
        public Integer getMedicalCardType() {
            return MedicalCardType;
        }

        public void setMedicalCardType(Integer medicalCardType) {
            MedicalCardType = medicalCardType;
        }

        @XmlElement(name = "MedicalCardId")
        public String getMedicalCardId() {
            return MedicalCardId;
        }

        public void setMedicalCardId(String medicalCardId) {
            MedicalCardId = medicalCardId;
        }

        @XmlElement(name = "ForbidFlag")
        public Integer getForbidFlag() {
            return ForbidFlag;
        }

        public void setForbidFlag(Integer forbidFlag) {
            ForbidFlag = forbidFlag;
        }

        @XmlElement(name = "ForbidDescribe")
        public String getForbidDescribe() {
            return ForbidDescribe;
        }

        public void setForbidDescribe(String forbidDescribe) {
            ForbidDescribe = forbidDescribe;
        }
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Patient {
        private String SourcePatientId;
        private String AuthorOrganization;
        private String IdCardCode;
        private String IdCard;
        private String Name;
        private String Sex;

        public String getSourcePatientId() {
            return SourcePatientId;
        }

        public void setSourcePatientId(String sourcePatientId) {
            SourcePatientId = sourcePatientId;
        }

        public String getAuthorOrganization() {
            return AuthorOrganization;
        }

        public void setAuthorOrganization(String authorOrganization) {
            AuthorOrganization = authorOrganization;
        }

        public String getIdCardCode() {
            return IdCardCode;
        }

        public void setIdCardCode(String idCardCode) {
            IdCardCode = idCardCode;
        }

        public String getIdCard() {
            return IdCard;
        }

        public void setIdCard(String idCard) {
            IdCard = idCard;
        }

        public String getName() {
            return Name;
        }

        public void setName(String name) {
            Name = name;
        }

        public String getSex() {
            return Sex;
        }

        public void setSex(String sex) {
            Sex = sex;
        }
    }
    @XmlRootElement(name = "LabRequest")
    public static class ExamLabRequest {
        private String RequestId;
        private Integer RequestSource;
        private Integer RequestStatus;
        private String RequestDateTime;
        private String RequestDoctor;
        private String RequestDoctorName;
        private String RequestDept;
        private String RequestDeptName;
        private List<ExamItemsResp> Items;

        @XmlElement(name = "RequestId")
        public String getRequestId() {
            return RequestId;
        }

        public void setRequestId(String requestId) {
            RequestId = requestId;
        }

        @XmlElement(name = "RequestSource")
        public Integer getRequestSource() {
            return RequestSource;
        }

        public void setRequestSource(Integer requestSource) {
            RequestSource = requestSource;
        }

        @XmlElement(name = "RequestStatus")
        public Integer getRequestStatus() {
            return RequestStatus;
        }

        public void setRequestStatus(Integer requestStatus) {
            RequestStatus = requestStatus;
        }

        @XmlElement(name = "RequestDateTime")
        public String getRequestDateTime() {
            return RequestDateTime;
        }

        public void setRequestDateTime(String requestDateTime) {
            RequestDateTime = requestDateTime;
        }

        @XmlElement(name = "RequestDoctor")
        public String getRequestDoctor() {
            return RequestDoctor;
        }

        public void setRequestDoctor(String requestDoctor) {
            RequestDoctor = requestDoctor;
        }

        @XmlElement(name = "RequestDoctorName")
        public String getRequestDoctorName() {
            return RequestDoctorName;
        }

        public void setRequestDoctorName(String requestDoctorName) {
            RequestDoctorName = requestDoctorName;
        }

        @XmlElement(name = "RequestDept")
        public String getRequestDept() {
            return RequestDept;
        }

        public void setRequestDept(String requestDept) {
            RequestDept = requestDept;
        }

        @XmlElement(name = "RequestDeptName")
        public String getRequestDeptName() {
            return RequestDeptName;
        }

        public void setRequestDeptName(String requestDeptName) {
            RequestDeptName = requestDeptName;
        }

        @XmlElementWrapper(name = "Items")
        @XmlElement(name = "Item")
        public List<ExamItemsResp> getItems() {
            return Items;
        }

        public void setItems(List<ExamItemsResp> items) {
            Items = items;
        }

        @XmlRootElement(name = "Item")
        @XmlAccessorType(XmlAccessType.FIELD)
        public static class ExamItemsResp {
            private String ItemCode;
            private String ItemName;
            private String SampleTypeCode;
            private String SampleTypeName;
            private Integer FeeStatus;
            private String AppointsValid;
            private String AppointsDescribe;
            private String SampleCollectAreaId;
            private String SampleCollectAreaName;

            public String getItemCode() {
                return ItemCode;
            }

            public void setItemCode(String itemCode) {
                ItemCode = itemCode;
            }

            public String getItemName() {
                return ItemName;
            }

            public void setItemName(String itemName) {
                ItemName = itemName;
            }

            public String getSampleTypeCode() {
                return SampleTypeCode;
            }

            public void setSampleTypeCode(String sampleTypeCode) {
                SampleTypeCode = sampleTypeCode;
            }

            public String getSampleTypeName() {
                return SampleTypeName;
            }

            public void setSampleTypeName(String sampleTypeName) {
                SampleTypeName = sampleTypeName;
            }

            public Integer getFeeStatus() {
                return FeeStatus;
            }

            public void setFeeStatus(Integer feeStatus) {
                FeeStatus = feeStatus;
            }

            public String getAppointsValid() {
                return AppointsValid;
            }

            public void setAppointsValid(String appointsValid) {
                AppointsValid = appointsValid;
            }

            public String getAppointsDescribe() {
                return AppointsDescribe;
            }

            public void setAppointsDescribe(String appointsDescribe) {
                AppointsDescribe = appointsDescribe;
            }

            public String getSampleCollectAreaId() {
                return SampleCollectAreaId;
            }

            public void setSampleCollectAreaId(String sampleCollectAreaId) {
                SampleCollectAreaId = sampleCollectAreaId;
            }

            public String getSampleCollectAreaName() {
                return SampleCollectAreaName;
            }

            public void setSampleCollectAreaName(String sampleCollectAreaName) {
                SampleCollectAreaName = sampleCollectAreaName;
            }
        }
    }

    public static void main(String[] args) {
        String xml = "<Data>\n" +
                "      <Patient>\n" +
                "        <SourcePatientId>6436</SourcePatientId>\n" +
                "        <AuthorOrganization>46640405-8</AuthorOrganization>\n" +
                "        <IdCard>441201195606086869</IdCard>\n" +
                "        <IdCardCode>01</IdCardCode>\n" +
                "        <Name>测算</Name>\n" +
                "        <Sex>2</Sex>\n" +
                "      </Patient>\n" +
                "      <Visit>\n" +
                "        <VisitOrganization>46640405-8</VisitOrganization>\n" +
                "        <VisitOrganizationName>创业慧康</VisitOrganizationName>\n" +
                "        <PatientType>1000</PatientType>\n" +
                "        <PatientTypeName/>\n" +
                "        <MedicalCardId>1908001975</MedicalCardId>\n" +
                "        <MedicalCardType>1</MedicalCardType>\n" +
                "        <ForbidFlag>0</ForbidFlag>\n" +
                "        <ForbidDescribe/>\n" +
                "      </Visit>\n" +
                "      <LabRequests>\n" +
                "        <LabRequest>\n" +
                "          <RequestId>5361</RequestId>\n" +
                "          <RequestSource>0</RequestSource>\n" +
                "          <RequestStatus>2</RequestStatus>\n" +
                "          <RequestDateTime>20230302T103159</RequestDateTime>\n" +
                "          <RequestDate>2023-03-02 10:31:59</RequestDate>\n" +
                "          <RequestDoctor>1000155</RequestDoctor>\n" +
                "          <RequestDoctorName>张大华</RequestDoctorName>\n" +
                "          <RequestDept>1153</RequestDept>\n" +
                "          <RequestDeptName/>\n" +
                "          <Items>\n" +
                "            <Item>\n" +
                "              <ItemCode>1240</ItemCode>\n" +
                "              <ItemName>肝功能</ItemName>\n" +
                "              <FeeStatus>0</FeeStatus>\n" +
                "              <SampleTypeCode>C</SampleTypeCode>\n" +
                "              <SampleTypeName>血液</SampleTypeName>\n" +
                "              <AppointsValid>1</AppointsValid>\n" +
                "              <AppointsDescribe>1、空腹采血，12h内禁止进食，3、24h内禁止饮酒</AppointsDescribe>\n" +
                "              <SampleCollectAreaId>6</SampleCollectAreaId>\n" +
                "              <SampleCollectAreaName>儿科采血处</SampleCollectAreaName>\n" +
                "            </Item>\n" +
                "          </Items>\n" +
                "        </LabRequest>\n" +
                "      </LabRequests>\n" +
                "    </Data>";
        ExamineAppointmentXmlResponse resResponse = JAXBUtils.xml2Object(xml, ExamineAppointmentXmlResponse.class);
        System.out.println(JSONUtils.writeValueAsString(resResponse));

    }
}
